﻿


CREATE proc [Notiz].[GetTelefonNotizTargetUser] 
	@inNotizID int = 0
as
begin
	if @inNotizID != 0
	begin
		select 
			nn.NotizID,
			nn.UserID,
			u.LoginName, 
			u.Vorname,
			u.Nachname,
			u.EMail
		from	Notiz.mnUserNotiz nn
				inner join [User].datUser u on
					u.UserID = nn.UserID
		where	(nn.NotizID = @inNotizID)
		order by u.LoginName
	end else
	begin
		select distinct
			0 'NotizID',
			u.UserID,
			u.LoginName, 
			u.Vorname,
			u.Nachname,
			u.EMail
		from	[User].datUser u
		order by u.LoginName
	end
end

GO


